//package com.dotflat.vod.controller;
//
//import com.dotflat.rest.controller.RestfulBaseController;
//import com.dotflat.vod.domain.OTCourse;
//import com.dotflat.vod.domain.OTCourseCheckRecord;
//import com.dotflat.vod.po.OTCourseCheckRecordPO;
//import com.dotflat.vod.service.OTCourseCheckRecordService;
//import com.dotflat.vod.service.OTCourseService;
//import com.matt.commons.dto.sso.StaffDTO;
//import com.matt.commons.exception.BusinessException;
//import com.matt.commons.model.StatusResponse;
//import com.matt.foundation.model.ErrorCode;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestHeader;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.util.ArrayList;
//import java.util.List;
//
//import static com.matt.foundation.constant.RequestConstant.TICKET;
//
//@RestController
//@RequestMapping("/api/otcourse/check_record")
//@Slf4j
//@Api(tags = "线下培训课 - 签到记录")
//public class OTCourseCheckRecordController extends RestfulBaseController<OTCourseCheckRecord, OTCourseCheckRecordService, OTCourseCheckRecordPO> {
//
//    @Autowired
//    public void setBaseService(OTCourseCheckRecordService service){
//        super.setBaseService(service);
//    }
//
//    @Autowired
//    private OTCourseService otCourseService;
//
//
//    @ApiOperation(value = "增加一条记录")
//    @PostMapping()
//    @Override
//    public StatusResponse add(@RequestHeader(TICKET) String ticket, OTCourseCheckRecordPO param){
//        StaffDTO staff = cache.getStaff(ticket);
//
//        String courseId = param.getOfflineCourseId();
//        OTCourse course = otCourseService.get(staff.getAreaId(), staff.getId(), courseId);
//
//        if (course == null){
//            throw new BusinessException(ErrorCode.COURSE_NOT_EXISTD, "培训课不存在");
//        }
//
//        OTCourseCheckRecord ret = baseService.add(staff.getAreaId(), staff.getId(), param, o->{
//            o.setStaffId(staff.getId());
//            o.setStaffHeadImg(staff.getHeadImgUrl());
//            o.setStaffName(staff.getRealName());
//        });
//
//        if (course.getVisitorCount() == null){
//            course.setVisitorCount(1);
//        }else {
//            course.setVisitorCount(course.getVisitorCount() + 1);
//        }
//        otCourseService.update(course);
//
//        List<OTCourseCheckRecord> tmp = new ArrayList<>();
//        tmp.add(ret);
//
//        return StatusResponse.success(tmp);
//    }
//
//}
